//
//  HPBoutiqueCell.m
//  wedding
//
//  Created by 常宽 on 15/1/16.
//  Copyright (c) 2015年 常宽. All rights reserved.
//

#define WIDTH self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height
#define HPBWidth self.HPBScrollView.frame.size.width / 5.5 * 2

#import "HPBoutiqueCell.h"  //本类,为精品婚礼与精品视频自定义cell类
#import "BoutiqueModel.h"   // 精品model类
#import "HPBoutique.h"      // 自定义View封装

@interface HPBoutiqueCell ()
/// 滚动视图
@property (nonatomic, retain)UIScrollView *HPBScrollView;
@end

@implementation HPBoutiqueCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.HPBScrollView = [[UIScrollView alloc]init];
        [self.contentView addSubview:_HPBScrollView];
        
        /// 初始化数据数组
        self.dataArray = [[NSMutableArray alloc] init];
    }
    return self;
}


- (void)layoutSubviews
{
    [super layoutSubviews];
    self.HPBScrollView.frame = self.contentView.bounds;
    self.HPBScrollView.backgroundColor = [WebColor lightPink];
    self.HPBScrollView.showsHorizontalScrollIndicator = NO;
    /// 数据传进来
    self.HPBScrollView.contentSize = CGSizeMake(self.dataArray.count * (HPBWidth + 5) + 5, 0);
    for (int i = 0; i < self.dataArray.count; i++) {
        HPBoutique *view = [[HPBoutique alloc]initWithFrame:CGRectMake(5 + (i *(HPBWidth + 5)), 5, HPBWidth, HEIGHT)];
        view.target = self;
        view.action = @selector(dianjilalalala:);
        BoutiqueModel *model = [self.dataArray objectAtIndex:i];
        view.model = model;
        [self.HPBScrollView addSubview:view];
    }
}
- (void)dianjilalalala:(HPBoutique *)sender
{
    NSLog(@"%@", sender.model.cate_name);
    self.actionBlock(sender.model);
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
